﻿namespace NMortgage.UI.Tests
{


    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using NMortgage.UI.Model;

    [TestClass]
    public class FeesValidatorTest : TestBase<FeeCollectionValidator>
    {
        #region Methods

        [TestMethod]
        public void Empty_list_should_not_be_valid()
        {
            var validationTarget = GetValidTarget();
            validationTarget.Clear();
            bool expected = false;
            bool actual = Subject.Validate(validationTarget).IsValid;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void FeesValidatorConstructorTest()
        {
            var target = new FeeCollectionValidator();
            Assert.IsNotNull(target);
        }

        [TestMethod]
        public void HaveValidChildrenTest()
        {
            FeeCollection validationTarget = GetInvalidTarget();

            bool expected = false;
            bool actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);

            validationTarget.Clear();
            validationTarget.Add(FeeCollectionTest.GetParameter0());
            validationTarget.Add(FeeCollectionTest.GetParameter1());
            validationTarget.Add(FeeCollectionTest.GetParameter2());

            expected = true;
            actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);

            validationTarget.Add(FeeCollectionTest.GetInvalidParameter0());
            expected = false;
            actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);
        }

        [TestInitialize]
        public void InitTest()
        {
            Subject = new FeeCollectionValidator();
        }

        private FeeCollection GetInvalidTarget()
        {
            var p = new FeeCollection();
            p.Add(FeeCollectionTest.GetParameter0());
            p.Add(FeeCollectionTest.GetInvalidParameter0());

            return p;
        }

        private FeeCollection GetValidTarget()
        {
            var p = new FeeCollection();
            p = new FeeCollection();
            p.Add(FeeCollectionTest.GetParameter0());
            p.Add(FeeCollectionTest.GetInvalidParameter0());

            return p;
        }

        #endregion Methods
    }
}